import React from 'react';
import { connect } from 'dva';
import { createForm } from 'rc-form';
import { List, Icon, TextareaItem } from 'antd-mobile';
import styles from './consultation.css';
import CustBtn from '../../../../../../common/buttons/Btn';
import content from '../../../../common/contentCss/content.css';
import CustTitle from '../../../../common/title/title';
import {ToastTips} from '../../../../../../common/toastTips/tosat';


const Consultation = ({
  onSubmit,
  goBack,
  form: { getFieldProps, getFieldsValue, validateFields },
}) => {

  const titleProps = {
    titleName:'咨询',
    goBack(){
      goBack();
    },
    showSaveBtnStatus:true,
    saveBtnName:'发送',
    onSave() {
      validData()
    },
  }
  const validData = () => {
    validateFields((error, value) => {
      // console.log(error, value);
      if (error) {
        for (var i in error) {
          error[i].errors.map(e => ToastTips(e.message, 1500, null))
        }
        return;
      }

      // console.log('value', JSON.stringify(value))
      onSubmit(value)
    });
  }

  return (
    <div className={content.content}>

      <CustTitle {...titleProps}/>
      <div style={{
        marginTop: '2.9em',
        marginBottom:'3.375em'
      }}>
      </div>
      <div>
        <TextareaItem className={styles.TextareaItem} cols={25} rows={8} placeholder="请输入您要咨询的问题"
          {...getFieldProps('askContent',{
            rules: [
              { required: true, message: '请输入您要咨询的问题' }
            ]
          })}
        />

      </div>

    </div>
  )
}


Consultation.propTypes = {
};

export default createForm()(Consultation);
